/**
*      author: Y_Yao
*      created: 2025-02-13 12:30:59
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 7;
const int M = 2e5 + 7;
int n,m,q;
int st,y;
int fa[M];
vector<int> s(M,1);
struct node
{
    int a,b,x;
};
struct qur
{
    int start,y,idex;
};

node a[M];

int find(int x)
{
    if(fa[x] == x) return x;
    else fa[x] = find(fa[x]);
    return fa[x];
}
void Union(int u,int v)
{
    int root1 = find(u);
    int root2 = find(v);
    if(root1 == root2) return;

    if(s[root1] > s[root2]) swap(root1,root2);
    fa[root1] = root2;
    s[root2] += s[root1];
}

void solve()
{
    cin >> n >> m >> q;
    for(int i = 0;i < n;i++) fa[i] = i;
    for(int i = 1;i <= m;i++)
    {
        node no;
        cin >> no.a >> no.b >> no.x;
        a[i] = no;
    }
    sort(a + 1,a + m + 1,[](node& t1,node& t2)->bool{
        return t1.x > t2.x;
    });

    vector<qur> qu;
    for(int i = 0;i < q;i++)
    {
        qur t1;
        cin >> t1.start;
        cin >> t1.y;
        t1.idex = i;
        qu.push_back(t1);
    }
    sort(qu.begin(),qu.end(),[](qur& a,qur& b)->bool{
        return a.y > b.y;
    });

    vector<int> ans(q);
    ans.resize(q);
    int ptr = 1;

    for(auto& e: qu)
    {
        int st = e.start;
        int y = e.y;
        int i = e.idex;
        while(ptr <= m && a[ptr].x >= y)
        {
            Union(a[ptr].a,a[ptr].b);
            ptr++;
        }

        int root = find(st);
        ans[i] = s[root];
    }

    for(auto& e : ans)
    {
        cout << e << endl;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}